import java.sql.Array;
import java.util.Arrays;

public class MyStack {
    private int []elem;
    public  int usedSize;

    //初始容量
    public static final int CAPACITY = 10;
    public MyStack() {

        this.elem = new int[CAPACITY];
    }
    //添加
    public void push(int val){
        if(isFull()){
            this.elem = Arrays.copyOf(this.elem,2*this.elem.length);
        }
        this.elem[usedSize] = val;
        this.usedSize++;
    }
    //判断容量
    private boolean isFull(){

        return this.usedSize == this.elem.length;
    }
    //删除
    public  int pop(){
        if(usedSize==0){
            return -1;
        }
        int a = elem[usedSize-1];
        usedSize--;
        return a;
    }
    //查看当前最后一个值
    public int peek(){
        if(usedSize==0){
            return -1;
        }
        return elem[usedSize-1];
    }



}

